﻿package FP 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import com.as3toolkit.ui.Keyboarder;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import FP.screen.InstScreen;
	import FP.screen.IntroScreen;
	import FP.screen.Screens;
	import FP.screen.TitleScreen;
	
	/**
	 * ...
	 * @author Ty Kimmey
	 */
	public class Document extends MovieClip
	{
		public var game:Game;
		public var kb:Keyboarder;
		public var levelXML:XML;
		//private var currentScreen:Screens;
		//public var myString:String = "Title";
		//public var ts:TitleScreen = new TitleScreen();
		
		
		
		public function Document():void 
		{
			kb = new Keyboarder(this);
			var XMLRequest:URLRequest = new URLRequest("levels.xml");
			var XMLLoader:URLLoader = new URLLoader(XMLRequest);
			XMLLoader.addEventListener(Event.COMPLETE, onXMLLoaded);			
		}
		
		public function onXMLLoaded(e:Event)
		{
			levelXML = new XML(e.target.data);			
		}
		
		// Does not actually seem necessary at the moment.
		/*public function nextScreen()
		{
			
			if (myString == "Title")
			{
				//var I:IntroScreen = new IntroScreen();
				//myString = "Intro";
				//gotoAndPlay("Intro");
			}
			else if (myString == "Intro")
			{
				var Inst:InstScreen = new InstScreen();
				myString = "Inst";
			}
			else if (myString == "Inst")
			{
				myString = "Game";
				nextScreen();
			}
			else if (myString == "Game")
			{
				game = new Game(levelXML);
				addChild(game);
				//game.init();
				game.begin();
			}
		}*/
		
		public function startGame()
		{
			game = new Game(levelXML);
			stage.addChild(game);
			//game.init();
			game.begin();
		}
	}

}